home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu086.dms / pu086.adf / clibs / libc.doc < prev    next >
Text File  |  1990-12-04  |  30KB  |  1,274 lines

  1.  
  2.   NorthC Version 1.3  (c) 1990 S.Hawtin.
  3.  
  4.   Permission is granted to copy this file and libc.a provided that:
  5.    1) Neither are used for commercial gain
  6.    2) This notice is included in all copies
  7.    3) Altered copies are marked as such
  8.    4) All copies of libc.a are accompanied by copies of this file.
  9.  
  10.   No liability is accepted for the contents of these files.
  11.  
  12.   libc.doc    within        NorthC library
  13.  
  14.   This file outlines the functions available within the 'NorthC' standard 
  15. 'C' library.  In this file I have just listed the functions that exist in 
  16. the 'C' library, I felt that it would be a waste of time to explain them 
  17. all in detail, there are a lot of books on 'C' that do that better than I 
  18. could.
  19.  
  20.   This file is split into three sections, firstly the NorthC specific 
  21. functions, next some general functions that are not part of ANSI and 
  22. finally the standard ANSI 'C' functions.  The only functions in the 
  23. library that are not described in this document are the AmigaDOS functions 
  24. that are supported, these are listed in the file "AmigaDOS.doc" within 
  25. this directory.
  26.  
  27.   The NorthC specific extensions are described in full, or at least as 
  28. close to full as you will find anywhere.
  29.  
  30.   The extra functions are outlined, they are mostly fairly obvious 
  31. extensions of the standard ANSI functions.
  32.  
  33.   A complete description of the ANSI C specifics can be obtained from any 
  34. book on ANSI C.  I have used the descriptions in the 1989 edition of 
  35. "Standard C" by Plauger & Brodie, published by Microsoft Press, "The Waite 
  36. Group's Essential Guide to ANSI C" by Naba Barkakati is another book that 
  37. describes all the ANSI functions quite well.  I have attempted to get as 
  38. close to the ANSI standard as possible and have tried to document all the 
  39. cases where the NorthC function deviates from the standard.
  40.  
  41.  
  42. NorthC Specifics
  43.  
  44.   When you create a program with NorthC it will automagically open the 
  45. 'dos.library', 'mathffp.library' and 'mathtrans.library'.  The 
  46. 'exec.library' is of course always open.  These libraries will be closed 
  47. for you when the program has completed.
  48.  
  49.   There are a number of other libraries within AmigaDOS 1.3 that you may 
  50. want to use, the stubs for most of these libraries are provided by the 
  51. NorthC 'C' library,
  52.  
  53.     Library                      Opened by
  54.     -------                      ---------
  55.     "diskfont.library"           OpenLibrary("diskfont.library",0L);
  56.     "dos.library"                - always open
  57.     "exec.library"               - always open
  58.     "expansion.library"          OpenLibrary("expansion.library",0L);
  59.     "graphics.library"           OpenLibrary("graphics.library",0L);
  60.     "icon.library"               OpenLibrary("icon.library",0L);
  61.     "intuition.library"          OpenLibrary("intuition.library",0L);
  62.     "layers.library"             OpenLibrary("layers.library",0L);
  63.     "mathffp.library"            - always open
  64.     "mathieeedoubbas.library"    - not supported
  65.     "mathieeedoubtrans.library"  - not supported
  66.     "mathtrans.library"          - always open
  67.     "translator.library"         OpenLibrary("translator.library",0L);
  68.  
  69. if you want to call any of the 'C' library routines within these libraries 
  70. you must ensure that it is open first.  It is important that you open the 
  71. library with a call to the routine OpenLibrary() from the NorthC 'C' 
  72. library otherwise the routines will not be able to find the library.  For 
  73. example
  74.  
  75.     extern long OpenLibrary();
  76.  
  77.     unsigned long icon_lib = 0;
  78.  
  79.     new_name(name)
  80.         char *name;
  81.        {char temp_name[32];
  82.         if (icon_lib==0)
  83.            {/* Call OpenLibrary(), 
  84.                NOTE second argument is 32 bits 0L not 0 */
  85.             icon_lib = OpenLibrary("icon.library",0L);
  86.             if(icon_lib==0)
  87.                {printf("Cannot open Icon.library\n");
  88.                 exit(10);
  89.                 }
  90.             }
  91.         BumpRevision(temp_name,name);
  92.         strcpy(name,temp_name);
  93.         }
  94.  
  95. by using the 'C' library OpenLibrary() call the library will be 
  96. automagically linked to the calling routines and closed when the program 
  97. calls exit(), or when the main() function returns.
  98.  
  99.  
  100. AMIGA NORTHC MC68000
  101.  
  102.   These three preprocessor symbols are set to 1 for each compilation.  Use 
  103. these in preprocessor statements to insert and remove sections of AMIGA or 
  104. NORTHC specific code.  See the documentation on setlocale() for an example 
  105. of how to use these symbols.
  106.  
  107.  
  108. char *chipcalloc(num_bytes,num)
  109.     int num_bytes;
  110.     int num;
  111.  
  112. char *chiprealloc(ptr,size)
  113.     char *ptr;
  114.     int  size;
  115.  
  116. char *chipmalloc(num_bytes)
  117.     int num_bytes;
  118.  
  119.   These three functions allocate space within the chip memory.  In NorthC 
  120. 1.2 there are three ways to ensure that you have "chip" memory, you can 
  121. allocate the space yourself with an AmigaDOS AllocMem() call, you can call 
  122. one of these three functions or you can call NorthC with the "-C" flag 
  123. set.  If you call AllocMem() you must ensure that the memory is freed 
  124. before you end the program, the 'C' library knows nothing about 
  125. AllocMem().  If you use the NorthC "-C" flag then all the static variables 
  126. within the file will be loaded into chip memory when you run the program, 
  127. I haven't fully tested this but it should work.
  128.  
  129.  
  130. char *_WBConsole
  131.  
  132.   This string describes the console the program should use when called 
  133. from the workbench, by default "con:20/20/400/100/NorthC Program", it is 
  134. specified by including a global variable declaration such as
  135.  
  136.     char *_WBConsole="newcon:0/0/640/200/My Prog";
  137.  
  138. in one of the source files of your program.  You could get by editing the 
  139. "defaults.c" program and adding the "defaults.o" file to your build.
  140.  
  141.  
  142. int _stdoutUnbuffered
  143.  
  144.   Most versions of 'C' buffer their output, that is when you call fputc() 
  145. the character doesn't get written to the file immediatly, the program 
  146. stores up the characters until it has a full line, then writes the whole 
  147. lot to the file in one go.  When you are dealing with files this is of 
  148. course the best thing to do, however 'C' also treats the standard output 
  149. as a file, if the standard output is buffered then you can get strange 
  150. effects for example
  151.  
  152.     printf("Type <Return>:");
  153.     getchar();
  154.  
  155. will not print the string "Type <Return>:" until you put an end of line in 
  156. the buffer by hitting the <Return> key.  You can get around this problem 
  157. with the fflush() function, but NorthC also allows the programmer to define 
  158. an integer called _stdoutUnbuffered if this is not zero then the "stdout" 
  159. file will be opened as an unbuffered file.  Again this is in the 
  160. "defaults.c" file.
  161.  
  162.  
  163. int _WithIntrCheck = 1;
  164.  
  165. void
  166. _CheckIntr()
  167.  
  168.   For this release I have taken a very simplistic attitude to interrupts, 
  169. whenever you output a character to a file or the terminal I check to see 
  170. if the user has pressed an interrupt key.  This means that file output is 
  171. slower than it was.  You can disable this function with the _WithIntrCheck 
  172. flag, if this is set to 0 then the function will not check the signals.  This 
  173. does mean that programs are larger than they need to be because all the 
  174. signal code is being added, if you define a function called _CheckIntr() in 
  175. you program then this will be called each time a character is output.
  176.  
  177.   If you have long loops with no file output then by calling _CheckIntr() 
  178. within them you will be able to stop the program with the <Control-C> key.
  179.  
  180.  
  181. debug()
  182.  
  183.   The NorthC 'C' library includes a function debug(), this allows computer 
  184. wizards to wander around the machine memory.  If the program executes a 
  185. call such as
  186.  
  187.     char *foo;
  188.     .
  189.     .
  190.     debug(foo);
  191.  
  192. then the routine will push the value foo on to the stack and print out 
  193. aline such as
  194.  
  195.       C00674:  80003132  ..12
  196.     NorthC:
  197.  
  198. this shows the address of the top of the stack, "C00674", and the contents 
  199. of the top of the stack in hexidecimal and ASCII.  The NorthC: prompt 
  200. shows that the routine is waiting for input, you can type the following characters
  201.  
  202.     Q   Quit the debugger and restart the program
  203.     X   eXit the debugger and exit() the program
  204.     R   Reset the address to its initial value at this level
  205.     <   Go up a level
  206.     >   Go down a level, make the contents of the current
  207.         location the address.  This will cause problems if
  208.         the current address contains an odd number.
  209.     +   Move the address on by 4, to next long word
  210.     -   Move the address back by 4
  211.     \   Move the address on by 2, to the next short word
  212.  
  213. if you type in a hexidecimal number it will be stored at the current 
  214. address.  If you want to examine a random address overwrite the top stack 
  215. element with the address you want to examine, then type '>'.  While using 
  216. debug() exercise extreme caution, it is easy to awaken the evil red guru.
  217.  
  218.  
  219. FOPEN_MODE  UNGET_TWICE  UNKNOWN_FILE  FILE_OFLOW  MALLOC_ZERO 
  220. NOT_YET_DONE  ASSERT_WRONG  FP_ERROR  WRITE_FAILED  SEEK_FAILED
  221.  
  222.   These are the error codes returned if the library is asked to do 
  223. something it doesn't like.  If your program dies with a message like 
  224. "Error: 1004" look in the ":include/errno.h" file to find out what it is 
  225. complaining about.  If you want to do it properly the function strerror() 
  226. will translate this error code into a string describing the error.
  227.  
  228.  
  229. _cmndlen  _cmndstr  _stdin  _stdout  _fromWB  _WBmsg  _Task
  230.  
  231.   When your program first starts the "crt0.asm" routines are called, these 
  232. set up some global variables as follows
  233.  
  234.     _cmndlen   the value of D0 at startup
  235.     _cmndstr   the value of A0 at startup
  236.     _stdin     the input file handle
  237.     _stdout    the output file handle
  238.     _fromWB    set to 0 if called from CLI
  239.     _WBmsg     the startup workbench message
  240.     _Task      the processes task structure
  241.  
  242. the _main() function uses these values to set up the argv[] array, and the 
  243. stdin, stdout and stderr file structures.  If for some reason you want to 
  244. get at the original startup string, or if you need to know when you were 
  245. called from the WorkBench you can use these variables, however if you 
  246. change them then any nasty effects are your fault.
  247.  
  248.  
  249. Special functions
  250.  
  251.   The standard 'C' library includes a number of functions that are not 
  252. part of ANSI C but are obvious extensions of functions that are.  This 
  253. section gives details of these functions.  Some of these originally came 
  254. from the Sozobon 'C' library on "FISH 171".
  255.  
  256.  
  257. void _div(ret,numer,denom)
  258.     div_t *ret;
  259.     int   numer;
  260.     int   denom;
  261.  
  262.   This function computes the quotient and remainder of (numer/denom) and 
  263. places the result in the structure pointed to by ret.  This function 
  264. allows programs that depend on the ANSI div() function to be ported to 
  265. NorthC, examine the section on div() to see how to use this function.
  266.  
  267.  
  268. void _ldiv(ret,numer,denom)
  269.     ldiv_t *ret;
  270.     long  numer;
  271.     long  denom;
  272.  
  273.   This function computes the quotient and remainder of (numer/denom) and 
  274. places the result in the structure pointed to by ret.  This is the long 
  275. version of _div().
  276.  
  277.  
  278. char *_tmpnam(base,str)
  279.     char *base;
  280.     char *str;
  281.  
  282.   This function returns a temporary filename, just like tmpnam().  The 
  283. name is created by adding a decimal number to the "base" string, for example
  284.  
  285.     foo = _tmpnam("df1:temp",NULL);
  286.  
  287. will set "foo" to a name such as "df1:temp47".  The name is guaranteed not 
  288. to be the name of an existing file.  As a matter of interest the function 
  289. tmpnam() is defined as
  290.  
  291.     char *
  292.     tmpnam(str)
  293.         char *str;
  294.        {return(_tmpnam("T:TEMP",str));
  295.         }
  296.  
  297. to create a filename in the "t:" directory.
  298.  
  299.  
  300. long fsystem(cmnd,infp,outfp)
  301.     char *cmnd;
  302.     FILE *infp;
  303.     FILE *outfp;
  304.  
  305.   This function performs a system() call, however when the program is 
  306. called it uses the file "infp" as "stdin" and "outfp" as "stdout" and 
  307. "stderr".  Like the Execute() function this will cause problems if you 
  308. attach a full file to "infp".
  309.  
  310.   This function is a half-way house between system(), that just calls the 
  311. command, and Execute(), that needs the file handles.  The function acts 
  312. like Execute() with FILE pointers.  Whatever you do don't pass stdin as 
  313. the value of "infp".
  314.  
  315.  
  316. char *itoa(n, buffer, radix)
  317.     int n;
  318.     char *buffer;
  319.     int radix;
  320.  
  321.   Print a representation of the integer n into the buffer, the radix can 
  322. be any value from 2 to 16.
  323.  
  324.  
  325. char *ltoa(n, buffer, radix)
  326.     long n;
  327.     char *buffer;
  328.     int radix;
  329.  
  330.   Print a representation of the long n into the buffer, radix can be any 
  331. value between 2 and 16.
  332.  
  333.  
  334. char *strdup(str)
  335.     char *str;
  336.  
  337.   Make a copy of the string that can be manipulated.
  338.  
  339.  
  340. int stricmp(str1, str2)
  341.     char *str1, *str2;
  342.  
  343.   Case independent string compare routine.
  344.  
  345.  
  346. int strirpl(string, ptrn, rpl, n)
  347.     char *string, *ptrn;
  348.     char *rpl;
  349.     int n;
  350.  
  351.   Case independent strrpl() routine.
  352.  
  353.  
  354. char *stristr(string, pattern)
  355.     char *string, *pattern;
  356.  
  357.   Case independent strstr().
  358.  
  359.  
  360. int strnicmp(str1, str2, limit)
  361.     char *str1, *str2;
  362.     int limit;
  363.  
  364.   Case independent versions of strncmp().
  365.  
  366.  
  367. char *strlwr(string)
  368.     char *string;
  369.  
  370.  Convert string to lower case.
  371.  
  372.  
  373. char *strnset(string, c, n)
  374.     char *string;
  375.     char c;
  376.     int n;
  377.  
  378.   Set the first n elements of the string to c.
  379.  
  380.  
  381. char *strset(string, c)
  382.     char *string;
  383.     char c;
  384.  
  385.   Set all the elements of a string to c.
  386.  
  387.  
  388. char *strpcpy(dest, start, end)
  389.     char *dest;
  390.     char *start;
  391.     char *end;
  392.  
  393.   Copy the string from start to end into dest.
  394.  
  395.  
  396. int strpos(string,c)
  397.     char *string;
  398.     char c;
  399.  
  400.   Return the index to the first occurrence of c in the string.
  401.  
  402.  
  403. char *strrev(string)
  404.     char *string;
  405.  
  406.   Reverse the string.
  407.  
  408.  
  409. int strrpl(string, ptrn, rpl, n)
  410.     char *string, *ptrn;
  411.     char *rpl;
  412.     int n;
  413.  
  414.   Replace the first n copies of ptrn with rpl, return the number of 
  415. replacements.  If n is -1 all copies will be replaced.
  416.  
  417.  
  418. int strrpos(string,c)
  419.     char *string;
  420.     char c;
  421.  
  422.   Find the index of the last character c in the string.
  423.  
  424.  
  425. char *strrpbrk(string, set)
  426.     char *string, *set;
  427.  
  428.   strpbrk() looking from the end of the string backwards.
  429.  
  430.  
  431. char *strupr(string)
  432.     char *string;
  433.  
  434.   Convert a string to upper case.
  435.  
  436.  
  437. char *ultoa(n, buffer, radix)
  438.     unsigned long n;
  439.     char *buffer;
  440.     int radix;
  441.  
  442.   Print the unsigned long n into the string using the base radix, radix 
  443. can be any value from 2 to 16.
  444.  
  445.  
  446. void
  447. _puts(str)
  448.     char *str;
  449.  
  450.   This function will output a string to stdout bypassing the normal 
  451. buffering mechanism, you should use this function within the signal() 
  452. routines as the interrupt signal can be raised when the program is in the 
  453. middle of outputting to the console normally.
  454.  
  455.  
  456. ANSI C
  457.  
  458.   Within the ANSI part of the library I have tried to follow the 
  459. standard,here is a list of the ANSI functions and macros, I have tried to 
  460. note all the special points.
  461.  
  462.  
  463. __FILE__  __LINE__  __DATE__  __TIME__    CLOCKS_PER_SEC CHAR_BIT  
  464. CHAR_MAX  CHAR_MIN  INT_MAX  INT_MIN  LONG_MAX  LONG_MIN SCHAR_MAX  
  465. SCHAR_MIN  SHRT_MAX  SHRT_MIN  UCHAR_MAX  UINT_MAX  ULONG_MAX USHRT_MAX  
  466. EXIT_FAILURE  EXIT_SUCCESS  MB_LEN_MAX  MB_CUR_MAX  RAND_MAX_IOFBF  
  467. _IOLBF  _IONBF  BUFSIZ  CHAR_BIT  CHAR_MAX  CHAR_MIN  EOF  FILE  
  468. FILENAME_MAX  FOPEN_MAX  L_tmpnam  NULL  TMP_MAX  EDOM  ERANGE
  469. SIGABRT  SIGFPE  SIGILL  SIGINT  SIGSEGV  SIGTERM  SIG_DFL  
  470. SIG_ERR  SIG_IGN
  471.  
  472.   All these are defined as normal.
  473.  
  474.  
  475. __STDC__
  476.  
  477.   This is not defined as NorthC is not a complete standard ANSI 'C'.
  478.  
  479.  
  480. SEEK_CUR  SEEK_END  SEEK_SET  
  481.  
  482.   The SEEK values are different from UNIX, AmigaDOS uses the more 
  483. intuitive -1, 0 and +1, this might cause problems when porting from UNIX 
  484. or MSDOS, if you find any code that calls fseek() with explicit numbers like
  485.  
  486.     fseek(fptr,0L,0);
  487.  
  488. you will have to change it to
  489.  
  490.     fseek(fptr,0L,SEEK_SET);
  491.  
  492. and slap the programmer that perpetrated the original code on the wrist.
  493.  
  494.  
  495. DBL_DIG  DBL_EPSILON  DBL_MANT_DIG  DBL_MAX  DBL_MAX_10_EXP  DBL_MAX_EXP 
  496. DBL_MIN  DBL_MIN_10_EXP  DBL_MIN_EXP  FLT_DIG  FLT_EPSILON  FLT_MANT_DIG  
  497. FLT_MAX  FLT_MAX_10_EXP  FLT_MAX_EXP  FLT_MIN  FLT_MIN_10_EXP  FLT_RADIX  
  498. FLT_ROUNDS  LDBL_DIG  LDBL_EPSILON  LDBL_MANT_DIG  LDBL_MAX  
  499. LDBL_MAX_10_EXP  LDBL_MAX_EXP  LDBL_MIN  LDBL_MIN_10_EXP  LDBL_MIN_EXP  
  500. LC_ALL  LC_COLLATE  LC_CTYPE  LC_MONETARY  LC_NUMERIC  LC_TIME 
  501.  
  502.   Not yet defined.
  503.  
  504.  
  505. void abort()
  506.  
  507. int abs(i)
  508.     int i;
  509.  
  510. double acos(num)
  511.     double num;
  512.  
  513.   Does not set errno to EDOM if |num| is greater than 1.
  514.  
  515. char *asctime(tptr)
  516.     struct tm *tptr;
  517.  
  518. double asin(num)
  519.     double num;
  520.  
  521.   Does not set errno to EDOM if |num| is greater than 1.
  522.  
  523. void assert(test)
  524.     int test;
  525.  
  526.   Will not print out the text of the test if the assertion is incorrect.
  527.  
  528. double atan(num)
  529.     double num;
  530.  
  531. double atan2(num1,num2)
  532.     double num1;
  533.     double num2;
  534.  
  535. int atexit(fun)
  536.     void (*fun)();
  537.  
  538. double atof(s)
  539.     char *s;
  540.  
  541. int atoi(s)
  542.     char *s;
  543.  
  544. long atol(s)
  545.     char *s;
  546.  
  547. char *bsearch(key,base,nelem,size,cmp)
  548.     char *key;
  549.     char *base;
  550.     int nelem;
  551.     int size;
  552.     int (*cmp)();
  553.  
  554. char *calloc(num_bytes,num)
  555.     int num_bytes;
  556.     int num;
  557.  
  558. double ceil(num)
  559.     double num;
  560.  
  561. void clearerr(stream)
  562.     FILE *stream;
  563.  
  564. clock_t clock()
  565.  
  566.   As in ANSI spec this function always returns -1 as I don't know how to 
  567. get hold of the elapsed processor time since the machine was booted.
  568.  
  569. typedef ... clock_t;
  570.  
  571. double cos(num)
  572.     double num;
  573.  
  574. double cosh(num)
  575.     double num;
  576.  
  577.   Does not set errno to ERANGE if num is too large.
  578.  
  579. char *ctime(cal)
  580.     time_t *cal;
  581.  
  582. double difftime(t1,t0)
  583.     time_t t1;
  584.     time_t t0;
  585.  
  586. div_t div(numer,denom)
  587.     int numer;
  588.     int denom;
  589.  
  590.   As I have no plans to implement structure returning functions this will 
  591. probably not be written.  Use the _div() function described in the 
  592. extensions section above, replace
  593.  
  594.     the_div = div(numer,denom);
  595.  
  596. with
  597.  
  598.     #ifndef NORTHC
  599.     the_div = div(numer,denom);
  600.     #else
  601.     _div(&the_div,numer,denom);
  602.     #endif
  603.  
  604. to achieve the same effect.
  605.  
  606. typedef ... div_t;
  607.  
  608. int errno;
  609.  
  610.   Not set in all the places it should be.
  611.  
  612. void exit(code)
  613.     int code;
  614.  
  615. double exp(num)
  616.     double num;
  617.  
  618.   Does not set errno to ERANGE if the argument is too large.
  619.  
  620. double fabs(num)
  621.     double num;
  622.  
  623. void fclose(stream)
  624.     FILE *stream;
  625.  
  626. int feof(stream)
  627.     FILE *stream;
  628.  
  629. int ferror(stream)
  630.     FILE *stream;
  631.  
  632. void fflush(stream)
  633.     FILE *stream;
  634.  
  635. char fgetc(stream)
  636.     FILE *stream;
  637.  
  638. int fgetpos(stream,pos)
  639.     FILE *stream;
  640.     int pos;
  641.  
  642. char *fgets(str, n, stream)
  643.     char *str;
  644.     int  n;
  645.     FILE *stream;
  646.  
  647. double floor(num)
  648.     double num;
  649.  
  650. double fmod(num1,num2)
  651.     double num1;
  652.     double num2;
  653.  
  654. FILE *fopen(fname,mode)
  655.     char *fname;
  656.     char *mode;
  657.  
  658. typedef ... fpos_t;
  659.  
  660. void fprintf(stream, format, ...)
  661.     FILE *stream;
  662.     char *format;
  663.  
  664. void fputc(c,stream)
  665.     char c;
  666.     FILE *stream;
  667.  
  668. int fputs(str,stream)
  669.     char *str;
  670.     FILE *stream;
  671.  
  672. int fread(ptr,size,nelem,stream)
  673.     char *ptr;
  674.     int  size;
  675.     int nelem;
  676.     FILE *stream;
  677.  
  678. void free(ptr)
  679.     char *ptr;
  680.  
  681. FILE *freopen(name,mode,stream)
  682.     char *name;
  683.     char *mode;
  684.     FILE *stream;
  685.  
  686. double frexp(x,pexp)
  687.     double x;
  688.     int *pexp;
  689.  
  690. void fscanf(stream, format, ...)
  691.     FILE *stream;
  692.     char *format;
  693.  
  694.   Floating point formats in scanf() don't work yet, however since they 
  695. don't work in the same way on any two 'C' compilers I am not worried.  If 
  696. you must read floating point numbers try fgets() and strtod().  NOTE some 
  697. UNIX 'C' libraries I know cannot even get strtod() right.
  698.  
  699. int fseek(stream,offset,mode)
  700.     FILE *stream;
  701.     long offset;
  702.     int  mode;
  703.  
  704. int fsetpos(stream,pos)
  705.     FILE *stream;
  706.     int  pos;
  707.  
  708. long ftell(stream)
  709.     FILE *stream;
  710.  
  711. int fwrite(ptr,size,nelem,stream)
  712.     char *ptr;
  713.     int  size;
  714.     int  nelem;
  715.     FILE *stream;
  716.  
  717. int getc(stream)
  718.     FILE *stream;
  719.  
  720. int getchar()
  721.  
  722. char *getenv(str)
  723.     char *str;
  724.  
  725.   Uses the "env:" directory to get the value of environment variables, 
  726. will only work under AmigaDOS 1.3 or later.
  727.  
  728. char *gets(s)
  729.     char *s;
  730.  
  731. struct tm *gmtime(tod)
  732.     time_t tod;
  733.  
  734.   Since I have no idea of the current time zone this is the same as 
  735. localtime(), this is normally good enough, at least here in the UK in the 
  736. winter.
  737.  
  738. int isalnum(c)
  739.     char c;
  740.  
  741. int isalpha(c)
  742.     char c;
  743.  
  744. int iscntrl(c)
  745.     char c;
  746.  
  747. int isdigit(c)
  748.     char c;
  749.  
  750. int isgraph(c)
  751.     char c;
  752.  
  753. int islower(c)
  754.     char c;
  755.  
  756. int isprint(c)
  757.     char c;
  758.  
  759. int ispunct(c)
  760.     char c;
  761.  
  762. int isspace(c)
  763.     char c;
  764.  
  765. int isupper(c)
  766.     char c;
  767.  
  768. int isxdigit(c)
  769.     char c;
  770.  
  771. typedef ... jmp_buf;
  772.  
  773. long labs(i)
  774.     long i;
  775.  
  776. struct lconv{...};
  777.  
  778.   I don't plan to implement any locale stuff, I have never met a program 
  779. that uses it (probably because I am English).
  780.  
  781. double ldexp(x,exp)
  782.     double x;
  783.     int    exp;
  784.  
  785. ldiv_t ldiv(numer,denom)
  786.     long numer;
  787.     long denom;
  788.  
  789.   No structure returns in NorthC, use the _ldiv() function as shown in the 
  790. div() description.
  791.  
  792. typedef ... ldiv_t;
  793.  
  794. struct lconv *localeconv()
  795.  
  796.   I have no plans to implement any of the locale stuff, just assume that 
  797. NorthC is always in the "C" locale.  If this is really required create an 
  798. lconv structure
  799.  
  800.     struct lconv
  801.        {char *currency_symbol;
  802.         char *decimal_point;
  803.         char *grouping;
  804.         char *int_curr_symbol;
  805.         char *mon_decimal_point;
  806.         char *mon_grouping;
  807.         char *mon_thousands_sep;
  808.         char *negative_sign;
  809.         char *positive_sign;
  810.         char *thousands_sep;
  811.         char frac_digits;
  812.         char int_frac_digits;
  813.         char n_cs_precedes;
  814.         char n_sep_by_space;
  815.         char n_sign_posn;
  816.         char p_cs_precedes;
  817.         char p_sep_by_space;
  818.         char p_sign_posn;
  819.         } mylconv = {"$",".","\3","USD ",".", "\3",",","-","+",",",
  820.                      2,2,1,0,4,  1,0,4};
  821.  
  822. and replace all calls to localeconv() with (&mylconv).
  823.  
  824. struct tm *localtime(tod)
  825.     time_t *tod;
  826.  
  827.   Same as gmtime() because I don't know which time zone we are in, for the 
  828. same reason the tm_isdst field is always 0.
  829.  
  830. double log(num)
  831.     double num;
  832.  
  833. double log10(num)
  834.     double num;
  835.  
  836. void longjmp(env,val)
  837.     jmp_buf env;
  838.     int val;
  839.  
  840. char *malloc(num_bytes)
  841.     int num_bytes;
  842.  
  843. int mblen(s,n)
  844.     char *s;
  845.     int n;
  846.  
  847.   Multibyte characters are not supported, replace all calls to mblen() with
  848.  
  849.     #ifndef NORTHC
  850.     foo = mblen(str,n);
  851.     #else
  852.     foo = (str==NULL?0:1);
  853.     #endif
  854.  
  855. this will be about the same.
  856.  
  857. int mbstowcs(wcs,s,n)
  858.     wchar_t *wcs;
  859.     char *s;
  860.     int  n;
  861.  
  862.   Multibyte characters are not supported, replace all calls to mbstowcs() with
  863.  
  864.     #ifndef NORTHC
  865.     foo = mbstowcs(wcs,s,n);
  866.     #else
  867.     foo = (s!=NULL?strncpy(wcs,s,n):0);
  868.     #endif
  869.  
  870. to emulate the mbstowcs() function.
  871.  
  872. int mbtowc(pwc,s,n)
  873.     wchar_t *pwc;
  874.     char *s;
  875.     int n;
  876.  
  877.   Multibyte characters are not supported, replace all calls to mbtowc() with
  878.  
  879.     #ifndef NORTHC
  880.     foo = mbtowc(wcs,s,n);
  881.     #else
  882.     foo = ((s!=NULL && n!=0)?*wcs=*s:0);
  883.     #endif
  884.  
  885. to emulate the function.
  886.  
  887. char *memchr(s,c,n)
  888.     char *s;
  889.     int c;
  890.     int n;
  891.  
  892. int memcmp(s1,s2,n)
  893.     char *s1;
  894.     char *s2;
  895.     int n;
  896.  
  897. void memcpy(dest,source,length)
  898.     char *dest;
  899.     char *source;
  900.     int  length;
  901.  
  902. char *memmove(s1,s2,n)
  903.     char *s1;
  904.     char *s2;
  905.     int  n;
  906.  
  907. char *memset(s,c,n)
  908.     char *s;
  909.     int  c;
  910.     int  n;
  911.  
  912. time_t mktime(tptr)
  913.     struct tm *tptr;
  914.  
  915.   Not yet written.  If you want to find out the real date of 57/57/1990 
  916. you can write the function yourself.  When you have done so send me a copy 
  917. and I will put it in the library.
  918.  
  919. double modf(x,pint)
  920.     double x;
  921.     double *pint;
  922.  
  923. int offsetof(type,member)
  924.  
  925. void perror(s)
  926.     char *s;
  927.  
  928. double pow(num1,num2)
  929.     double num1;
  930.     double num2;
  931.  
  932.   Does not set errno to EDOM when it should.
  933.  
  934. void printf(format, ...)
  935.     char *format;
  936.  
  937. typedef ... ptrdiff_t;
  938.  
  939. int putc(c,stream)
  940.     int c;
  941.     FILE *stream;
  942.  
  943. int putchar(c)
  944.     int c;
  945.  
  946. int puts(s)
  947.     char *s;
  948.  
  949. void qsort(base,nelem,size,cmp)
  950.     char *base;
  951.     int  nelem;
  952.     int  size;
  953.     int (*cmp)();
  954.  
  955. int raise(sig)
  956.     int sig;
  957.  
  958. int rand()
  959.  
  960. char *realloc(ptr,size)
  961.     char *ptr;
  962.     int  size;
  963.  
  964.   Always creates a new block, never reuses the old location.
  965.  
  966. int remove(name)
  967.     char *name;
  968.  
  969. int rename(old,new)
  970.     char *old;
  971.     char *new;
  972.  
  973. int rewind(stream)
  974.     FILE *stream;
  975.  
  976. void scanf(format, ...)
  977.     char *format;
  978.  
  979.   Cannot read floating point formats, see fscanf().
  980.  
  981. void setbuf(stream,buf)
  982.     FILE *stream;
  983.     char *buf;
  984.  
  985. int setjmp(env)
  986.     jmp_buf env;
  987.  
  988. char *setlocale(cat,locale)
  989.     int cat;
  990.     char *locale;
  991.  
  992.   Locales are not supported, if you want to fake it assume that NorthC is 
  993. always in the "C" locale.  Replace all calls with
  994.  
  995.     #ifndef NORTHC
  996.     loc = setlocale(cat,locale);
  997.     #else
  998.     loc = ((locale==NULL || strcmp(locale,"C")==0)?"C":NULL);
  999.     #endif
  1000.  
  1001. this will fake the call.
  1002.  
  1003. int setvbuf(stream,buf,mode,size)
  1004.     FILE *stream;
  1005.     unsigned char *buf;
  1006.     int mode;
  1007.     int size;
  1008.  
  1009. void (*signal(sig,fun)
  1010.     int sig;
  1011.     void (*fun)();)()
  1012.  
  1013.   The only signals you can get are SIGABRT, from the abort() function, and 
  1014. SIGINT from the user hitting an interrupt key on the keyboard.
  1015.  
  1016.  
  1017. typedef ... sig_atomic_t;
  1018.  
  1019. double sin(num)
  1020.     double num;
  1021.  
  1022. double sinh(num)
  1023.     double num;
  1024.  
  1025. typedef ... size_t;
  1026.  
  1027. void sprintf(buf, format, ...)
  1028.     char *buf;
  1029.     char *format;
  1030.  
  1031. double sqrt(num)
  1032.     double num;
  1033.  
  1034.   Does not set errno to EDOM if num is negative.
  1035.  
  1036. void srand(seed)
  1037.     int seed;
  1038.  
  1039. void sscanf(buf, format, ...)
  1040.     char *buf;
  1041.     char *format;
  1042.  
  1043.   Cannot read floating point formats yet, see fscanf().
  1044.  
  1045. FILE *stderr,*stdin,*stdout;
  1046.  
  1047. char *strcat(dest, source)
  1048.     char *dest, *source;
  1049.  
  1050. char *strchr(string, symbol)
  1051.     char *string;
  1052.     char symbol;
  1053.  
  1054. int strcmp(str1, str2)
  1055.     char *str1;
  1056.     char *str2;
  1057.  
  1058. int strcoll(str1,str2)
  1059.     char *str1;
  1060.     char *str2;
  1061.  
  1062.   Since locales are not supported this function does not exist.  If you 
  1063. want to fake it replace all calls with
  1064.  
  1065.     #ifndef NORTHC
  1066.     val = strcoll(str1,str2);
  1067.     #else
  1068.     val = strcmp(str1,str2);
  1069.     #endif
  1070.  
  1071. this will do the right type of thing.
  1072.  
  1073. char *strcpy(to, from)
  1074.     char *to;
  1075.     char *from;
  1076.  
  1077. int strcspn(str, set)
  1078.     char *str;
  1079.     char *set;
  1080.  
  1081. char *strerror(code)
  1082.     int code;
  1083.  
  1084. long strftime(s,n,format,tptr)
  1085.     char *s;
  1086.     size_t n;
  1087.     char *format;
  1088.     struct tm *tptr;
  1089.  
  1090.   The "%U" and "%W" specifiers are not implemented.  The "%Z" specifier is 
  1091. ignored, because I have no idea of the timezone.
  1092.  
  1093. int strlen(string)
  1094.     char *string;
  1095.  
  1096. char *strncat(dest, source, limit)
  1097.     char *dest, *source;
  1098.     int limit;
  1099.  
  1100. int strncmp(str1, str2, limit)
  1101.     char *str1, *str2;
  1102.     int limit;
  1103.  
  1104. char *strncpy(dest, source, limit)
  1105.     char *dest, *source;
  1106.     int limit;
  1107.  
  1108. char *strpbrk(string, set)
  1109.     char *string, *set;
  1110.  
  1111. char *strrchr(string, symbol)
  1112.     char *string;
  1113.     char symbol;
  1114.  
  1115. int strspn(string, set)
  1116.     char *string, *set;
  1117.  
  1118. char *strstr(string, pattern)
  1119.     char *string, *pattern;
  1120.  
  1121. double strtod(s,endptr)
  1122.     char *s;
  1123.     char **endptr;
  1124.  
  1125.   Does not set errno to ERANGE if the number is too large.
  1126.  
  1127. char *strtok(string, delim)
  1128.     char *string, *delim;
  1129.  
  1130. long strtol(number, nptr, base)
  1131.     char *number;
  1132.     char **nptr;
  1133.     int base;
  1134.  
  1135.   No overflow checking or setting of errno.
  1136.  
  1137. unsigned long strtoul(number, nptr, base)
  1138.     char *number;
  1139.     char **nptr;
  1140.     int base;
  1141.  
  1142.   No overflow checking or setting of errno.
  1143.  
  1144. int strxfrm(s1,s2,n)
  1145.     char *s1;
  1146.     char *s2;
  1147.     int  n;
  1148.  
  1149.   Locales are not supported in NorthC.  You can fake the call with
  1150.  
  1151.     #ifndef NORTHC
  1152.     num = strxfrm(s1,s2,n);
  1153.     #else
  1154.     num = strncpy(s1,s2,n);
  1155.     #endif
  1156.  
  1157. long system(cmnd)
  1158.     char *cmnd;
  1159.  
  1160.   Executes CLI commands, assigns NULL to the input and output files, if 
  1161. you want to attach a file use fsystem().  This function should return the 
  1162. exit code of the program called, since I cannot work out how to get this 
  1163. it always returns the value returned by the Execute() function, that is -1.
  1164.  
  1165. double tan(num)
  1166.     double num;
  1167.  
  1168.   Does not set errno to EDOM if num is an odd multiple of PI/2.
  1169.  
  1170. double tanh(num)
  1171.     double num;
  1172.  
  1173. time_t time(tod)
  1174.     time_t *tod;
  1175.  
  1176. struct tm {...};
  1177.  
  1178. FILE *tmpfile()
  1179.  
  1180.   I am not sure how to create a file that disappears when it is closed, so 
  1181. this function does not yet exist.  If you want to emulate it you could try 
  1182. something like
  1183.  
  1184.     #ifdef NORTHC
  1185.     char TempFileName[L_tmpnam];
  1186.     char *TPtr;
  1187.  
  1188.     DelTempFile()
  1189.        {/* Delete the created temp file */
  1190.         remove(TempFileName);
  1191.         }
  1192.     #endif
  1193.     .
  1194.     .
  1195.     #ifndef NORTHC
  1196.     fptr = tmpfile();
  1197.     #else
  1198.     TPtr = tmpnam();
  1199.     if(TPtr)
  1200.        {fptr = fopen(TPtr,"w+");
  1201.         strcpy(TempFileName,TPtr);
  1202.         atexit(DelTempFile);
  1203.         }
  1204.     #endif
  1205.  
  1206. and make sure that you close the file before exiting the program.
  1207.  
  1208. char *tmpnam(s)
  1209.     char *s;
  1210.  
  1211.   Always creates a file name in the "t:" directory, this is usually on the 
  1212. ram disk, use the "assign" command to put "t:" somewhere else if you want 
  1213. to move it.  If you want to create a temporary file in your current 
  1214. directory use _tmpnam().
  1215.  
  1216. char tolower(ch)
  1217.     char ch;
  1218.  
  1219. char toupper(ch)
  1220.     char ch;
  1221.  
  1222. void ungetc(ch,stream)
  1223.     char ch;
  1224.     FILE *stream;
  1225.  
  1226. va_arg va_end va_list va_start
  1227.  
  1228. void vfprintf(stream, format, ap)
  1229.     FILE *stream;
  1230.     char *format;
  1231.     va_list ap;
  1232.  
  1233. void vprintf(format, ap)
  1234.     char *format;
  1235.     va_list ap;
  1236.  
  1237. void vsprintf(buf, format, ap)
  1238.     char *buf;
  1239.     char *format;
  1240.     va_list ap;
  1241.  
  1242. typedef ... wchar_t;
  1243.  
  1244. int wcstombs(s,wcs,n)
  1245.     char *s;
  1246.     wchar_t *wcs;
  1247.     int n;
  1248.  
  1249.   No multibyte characters so this function does not exist, you can fake it 
  1250. with
  1251.  
  1252.     #ifndef NORTHC
  1253.     num = wcstombs(s,wcs,n);
  1254.     #else
  1255.     num = strncpy(s,wcs,n);
  1256.     #endif
  1257.  
  1258. this will perform the same type of function.
  1259.  
  1260. int wctomb(s,wchar)
  1261.     char *s;
  1262.     wchar_t *wchar;
  1263.  
  1264.   There are no multibyte characters in NorthC. You can emulate this 
  1265. function with
  1266.  
  1267.     #ifndef NORTHC
  1268.     num = wctomb(s,wchar);
  1269.     #else
  1270.     *s=*wchar;
  1271.     num = 1;
  1272.     #endif
  1273.  
  1274.